package com.bloody.android;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class EndGame extends PlayerWindowInteraction implements OnClickListener{
	
	private TextView title;
	private ArrayList<TextView> characterPlayerOne;
	private ArrayList<TextView> characterPlayerTwo;
	private Button back;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.end_game);
        
        Bundle bundle = this.getIntent().getExtras();
        
        title = (TextView)findViewById(R.id.title_end_game);
        Log.d("DEBUG", ""+title);
        Log.d("DEBUG", ""+bundle.getInt("playerWin"));
        title.setText("Le joueur " +bundle.getInt("playerWin")+" a vaincu!");
        
        back = (Button)findViewById(R.id.back_end_game);
        back.setOnClickListener(this);
        
        characterPlayerOne = new ArrayList<TextView>();
        characterPlayerTwo = new ArrayList<TextView>();
        
        characterPlayerOne.add((TextView)findViewById(R.id.ch1_1));
        characterPlayerOne.add((TextView)findViewById(R.id.ch1_2));
        characterPlayerOne.add((TextView)findViewById(R.id.ch1_3));
        
        characterPlayerTwo.add((TextView)findViewById(R.id.ch2_1));
        characterPlayerTwo.add((TextView)findViewById(R.id.ch2_2));
        characterPlayerTwo.add((TextView)findViewById(R.id.ch2_3));
        
        for (int i=0; i<characterPlayerOne.size(); i++){
        	String characterName = bundle.getString("ch1_"+i+"_name");
        	characterPlayerOne.get(i).setText(characterName);
       		characterPlayerOne.get(i).setTextColor(0xFF00FF00);
        }
        
        for (int i=0; i<characterPlayerTwo.size(); i++){
        	String characterName = bundle.getString("ch2_"+i+"_name");
        	characterPlayerTwo.get(i).setText(characterName);
        	characterPlayerTwo.get(i).setTextColor(0xFF00FF00);
        }
	}

	@Override
	public void onClick(View v) {
		if (v == back) {
			setResult(RESULT_OK);
			finish();
		}
	}
}
